package com.aboo.util;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

/**
 * ArrayList工具包
 * @author Yata Aboo
 *
 */
public class ArrayListUtils<U, T> {
	
	protected static final Logger logger = Logger.getLogger(ArrayListUtils.class);

	/**
	 * 随机重组ArrayList
	 * @param arrryList  待重组的ArrayList
	 * @return  随机重组好的ArrayList
	 */
	public static ArrayList<Object> random(ArrayList<Object> arrryList) {
		ArrayList<Object> newArrayList = new ArrayList<Object>();
		java.util.Random random = new java.util.Random();
		for (int i = arrryList.size(); i > 0; i--) {
			newArrayList.add(arrryList.remove(random.nextInt(i)));
		}
		return newArrayList;
	}
	
	public List<U> convert(List<T> input) {
		List<U> output = null;;
		if (input != null) {
			output = new ArrayList<U>();
			for (T obj : input) {
				output.add((U) obj);
			}
		}
		
		return output;
	}

}
